package com.malljelly.study.producer;

/**
 * Created by 骑着蜗牛去旅行 on 2018/8/12.
 */

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;

import javax.jms.Queue;

/**
 * 消息生产者
 */
@Slf4j
@Component
public class MessageProducerService {

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Autowired
    private Queue queue;

    /**
     * 发送消息
     * @param msgJson
     */
    public void sendMessage(String msgJson) {
        this.jmsMessagingTemplate.convertAndSend(queue, msgJson);
    }
}
